package org.haifi.service;

import java.io.File;
import java.util.Enumeration;
import java.util.logging.LogManager;

import org.apache.commons.io.FileUtils;
import org.apache.log4j.Logger;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.junit.Test;

/**
 * 测试下动态调整log4j的日志输出级别
 * 
 * @author joycube2
 * 
 */
public class Log4jTest1 extends GameBaseManagerTestCase {
	@Test
	public void test1() {
		try {
			// SAXReader reader = new SAXReader();
			// String a=FileUtils.readFileToString(new
			// File(Thread.currentThread()
			// .getContextClassLoader().getResource( "log4j.xml").toURI()));
			// Document document =DocumentHelper.parseText(a);

			// log.info(document.asXML());

			// 草了，难道就不能通过log4j获得吗，非得从xml中读吗
			Enumeration<String> aaa = LogManager.getLogManager()
					.getLoggerNames();
			while (aaa.hasMoreElements()) {
				log.info(aaa.nextElement());
			}
			
			Enumeration logManager=org.apache.log4j.LogManager.getCurrentLoggers();
			while(logManager.hasMoreElements()){
				Logger logger=(Logger)logManager.nextElement();
				log.info(logger.getName()+"\t"+logger.getLevel());
			}
		} catch (Exception e) {
			log.error("ERROR", e);
		}
	}
}
